<template>
  <el-main>
    <Navbar></Navbar>
    <div id="chart" style="height:80vh"></div>
  </el-main>
</template>

<script>
import * as echarts from 'echarts'
import { getReportSetMeal } from '@/api'

export default {
  watch: {},
  methods: {
    drawChart() {
      getReportSetMeal().then((res) => {
        let myChart = echarts.init(document.getElementById('chart'));
        myChart.setOption({
          title : {
            text: '套餐预约占比',
            subtext: '',
            x:'center'
          },
          tooltip : {//提示框组件
            trigger: 'item',//触发类型，在饼形图中为item
            formatter: "{a} <br/>{b} : {c} ({d}%)"//提示内容格式
          },
          legend: {//图例
            orient: 'vertical',
            left: 'left',
            data: res.data.data.setmealNames
          },
          series : [//数据系列
            {
              name: '套餐预约占比',
              type: 'pie',//饼形图
              radius : '55%',
              center: ['50%', '60%'],
              data:res.data.data.setmealCount,
              itemStyle: {
                emphasis: {
                  shadowBlur: 10,
                  shadowOffsetX: 0,
                  shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
              }
            }
          ]
        })
      })
    }
  },
  mounted() {
    this.drawChart()
  }
}
</script>

<style lang="less">
.box {
  position: relative;
  border-radius: 3px;
  background: #ffffff;
  padding: 10px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.boxMain .el-upload--text{
  position:static;
}
.boxMain >div{
  display: inline-block;
}
.excelTitle{
  text-align: center;
  overflow: hidden;
  line-height: 40px;
}
.excelTitle .el-button{
  float: left;
}
.excelTime{
  padding: 10px 0;
  text-align: right;
}
.exceTable{
  width: 100%;
  border-right: 1px solid #e6e6e6;
  border-bottom: 1px solid #e6e6e6;
  font-size: 14px;
  color: #333;
}
.exceTable tr,.exceTable td{
  border-left: 1px solid #e6e6e6;
  border-top: 1px solid #e6e6e6;
  height: 40px;
  line-height: 40px;
  padding: 0 10px;
}
.exceTable .headBody{
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}
.tabletrBg{
  background: #fcfcfc;
  text-align: right;
}

</style>